home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / vogle / prev.lha / smalloc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-29  |  391 b   |  29 lines

  1. #include <stdio.h>
  2.  
  3. extern char    *malloc();
  4.  
  5. /*
  6.  * smalloc
  7.  *
  8.  *    allocates memory - checking for null
  9.  */
  10. char *
  11. smalloc(size)
  12.     unsigned    size;
  13. {
  14.     char    *p, *p2, buf[BUFSIZ];
  15.  
  16.     if ((p = malloc(size)) == (char *)NULL) {
  17.         sprintf(buf, "smalloc: request for %d bytes from malloc returns NULL.\n", size);
  18.         fatal(buf);
  19.     }
  20.  
  21.     /*
  22.     for (p2 = p; p2 != p + size; p2++)
  23.         *p2 = 0xff;
  24.     */
  25.  
  26.     return(p);
  27. }
  28.  
  29.